<?php
/**
 * Base Controller
 * @author cuonglv@vietincom.com
 * */

class BaseController extends Controller{
    public $obj;
    public $data = array();

    function __construct(){
        parent::Controller();
        $this->load->helper('url');

        if($this->uri->segment(3) == FALSE || $this->uri->segment(3)=='vn')
        {
            $this->lang->load('vn','vn');
            $langType = 'vn';
        }
        else
        {
            $this->lang->load('en','en');
            $langType = 'en';
        }

        $data['lang'] = $this->lang;
        $data['langType'] = $langType;
        $data['baseUrl'] = base_url();

        return $data;
    }

    function _getInputData()
    {
		$arrKey = array_keys((array)$this->obj);
		foreach($arrKey as $key)
		{
			$this->obj->$key = $this->input->post($key);
		}
		return $this->obj;
    }

    private function method()
    {
        $method = 'undefined';
        if(isset($_SERVER['REQUEST_METHOD']))
        {
        $method = strToLower($_SERVER["REQUEST_METHOD"]);
        }
        return $method;
    }

    public function _isGet()
    {
        return ($this->method()=='get');
    }

    public function _isPost()
    {
        return ($this->method()=='post');
    }
}
?>
